//
//  YXUtility.m
//  PurchasingMeeting
//
//  Created by zhuang yihang on 7/20/13.
//  Copyright (c) 2013 YX. All rights reserved.
//

#import "YXUtility.h"

static YXUtility *_gInstance = nil;

@interface YXUtility(){
}

@end

@implementation YXUtility

+ (YXUtility *)getInstance {
    @synchronized( [YXUtility class] ){
        if(!_gInstance)
            _gInstance = [[self alloc] init];
        return _gInstance;
    }
    return nil;
}

+ (id)alloc {
    @synchronized ([YXUtility class]){
        NSAssert(_gInstance == nil,
                 @"Attempted to allocated a second instance");
        _gInstance = [super alloc];
        return _gInstance;
    }
    return nil;
}

- (id)init {
    self = [super init];
    if (self) {
        
    }
    return self;
}


- (NSString *)getRandomString:(int)length{
    static NSString* list = @"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    NSMutableString *str = [NSMutableString string];
    for (int i = 0; i < length; i++) {
        NSString *s = [list substringWithRange:NSMakeRange(arc4random()%list.length, 1)];
        [str appendString:s];
    }
    
    return str;
}

@end
